﻿using UnityEngine;
using System.Collections;
using System.Diagnostics;

public class TestProfiler : MonoBehaviour
{

    // Use this for initialization
    void Start()
    {
        float t = Time.time;
        testMethod();
        UnityEngine.Debug.Log(string.Format("totalTime:{0}",(Time.time-t)));

        Stopwatch st = new Stopwatch();
        st.Start();
        testMethod();
        st.Stop();
        UnityEngine.Debug.Log(string.Format("TotalTime:{0}",st.ElapsedMilliseconds));

        Profiler.BeginSample("TestMethod");//Profiler下查看testMethod的运行时间
        testMethod();
        Profiler.EndSample();
    }


    void testMethod()
    {
        for (int i = 0; i < 10000000; i++)
        {

        }
    }
}
